﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using WcfClientGenerator.UI.Util;

namespace WcfClientGenerator.UI.Converters
{
    public class ConfigurationBackgroundConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int colorIndex = (int)value;
            Color color = new Color();
            try
            {
                color = TileBackground.GetColor(colorIndex);
            }
            catch (IndexOutOfRangeException)
            {
                color = TileBackground.Default;
            }
            return new SolidColorBrush(color);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
